#ifndef _BITERM_H
#define _BITERM_H

#include <cmath>
#include <string>
#include <sstream>
#include <cassert>

using namespace std;

class Biterm {
private:
  int wi;
  int wj;
  int t;				// t=0, common biterm; t=1, bursty biterm
  int z;				// topic assignment
  double pt_b;			// p(t|w1, w2)

public: 
  Biterm(int w1, int w2): z(-1), t(-1) {
	wi = min(w1, w2);
	wj = max(w1, w2);
  }

  // s format:wi-wj:z
  Biterm(string s) {
	istringstream iss(s);
	iss >> wi >> wj >> pt_b;
  }

  int get_wi() const {return wi;}
  int get_wj() const {return wj;}

  double get_pt_b() const {return pt_b;}
  
  int get_t() {return t;}

  int get_z() const {return z;}
  void set_z(int type, int k) {t = type; z = k;}
  void reset_z() {t = -1; z = -1;}
  
  string str() const {
	ostringstream os;
	os << wi << ' ' << wj << '\t' << t << '\t' 
	   << z << '\t' << pt_b;
	return os.str();
  }  
};

#endif
